package tuanda.soict.firstsun.PresentationPackage;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table;

public class WinScreen extends AbstractScreen {

	private Table table;
	private Button backButton;
	private Label text;

	public WinScreen(Object[] inputData, TalesOfTroubadour game) {
		super(inputData, game);
		Skin skin = getSkin();
		table = new Table(skin);
		text = new Label(((String) inputData[0]).toUpperCase(), skin);
		backButton = new TextButton("BACK", skin);
		backButton.setClickListener(new ClickListener() {
			@Override
			public void click(Actor actor, float x, float y) {
				myGame.setScreen(
						new StartScreen(null, myGame));
			}
		});
		table.right().bottom().setFillParent(true);
		table.defaults().right().bottom().minWidth(100).spaceBottom(5);
		Texture image = new Texture(Gdx.files.internal("Images/SunRise.jpg"));
		image.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		table.setBackground(new NinePatch(image));
		table.add(text).expandY().top().center();
		table.row();
		table.add(backButton).center();
		table.row();
	}

	public void dispose() {
		super.dispose();
	}

	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
		stage.setViewport(width, height, true);
	}

	@Override
	public void render(float delta) {
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		stage.addActor(table);
		stage.draw();
	}
}
